//2009/08/26 19:56:30
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class BoxesOfBooks
{
public:
    int boxes(vector <int> weights, int maxWeight)
    {
		int ret = 0;
		//sort(weights.begin(), weights.end());
		int v = maxWeight;
		for(int i=0; i<weights.size(); i++)
		{
			if(v >= weights[i]) v -= weights[i];
			else 
			{
				ret ++;
				v = maxWeight - weights[i];
			}
		}
		if(v < maxWeight) ret ++;
		return ret;
    }
};
